﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PersistentObject.Common.Criteria
{
    /// <summary>
    /// Represent a BINARY clause which is like LEFT comparison RIGHT
    /// </summary>
    public class BinaryCriteria : BaseCriteria
    {
        /// <summary>
        /// Indicate the LEFT operand
        /// </summary>
        public Operand Left { get; private set; }
        /// <summary>
        /// Indicate the RIGHT operand
        /// </summary>
        public Operand Right { get; private set; }
        /// <summary>
        /// Indicate the comparison between LEFT operand and RIGHT operand
        /// </summary>
        public BinaryComparison Comparison { get; private set; }

        /// <summary>
        /// The constructor of BINARY criteria with default EQUAL comparison
        /// </summary>
        /// <param name="left">Indicate the LEFT property operand</param>
        /// <param name="right">Indicate the RIGHT value operand</param>
        public BinaryCriteria(string left, object right)
        {
            Left = new OperandProperty(left);
            Right = new OperandValue(right);
            Comparison = BinaryComparison.Equal;
        }

        /// <summary>
        /// The constructor of BINARY criteria
        /// </summary>
        /// <param name="left">Indicate the LEFT property operand</param>
        /// <param name="right">Indicate the RIGHT value operand</param>
        /// <param name="comparison">Indicate the comparison</param>
        public BinaryCriteria(string left, object right, BinaryComparison comparison)
        {
            Left = new OperandProperty(left);
            Right = new OperandValue(right);
            Comparison = comparison;
        }

        /// <summary>
        /// The constructor of BINARY criteria
        /// </summary>
        /// <param name="left">Indicate the LEFT operand</param>
        /// <param name="right">Indicate the RIGHT value operand</param>
        public BinaryCriteria(Operand left, object right)
        {
            Left = left;
            Right = new OperandValue(right);
            Comparison = BinaryComparison.Equal;
        }

        /// <summary>
        /// The constructor of BINARY criteria
        /// </summary>
        /// <param name="left">Indicate the LEFT operand</param>
        /// <param name="right">Indicate the Right value operand</param>
        /// <param name="comparison">Indicate the comparison</param>
        public BinaryCriteria(Operand left, object right, BinaryComparison comparison)
        {
            Left = left;
            Right = new OperandValue(right);
            Comparison = comparison;
        }

        /// <summary>
        /// The constructor of BINARY criteria
        /// </summary>
        /// <param name="left">Indicate the LEFT property operand</param>
        /// <param name="right">Indicate the RIGHT operand</param>
        public BinaryCriteria(string left, Operand right)
        {
            Left = new OperandProperty(left);
            Right = right;
            Comparison = BinaryComparison.Equal;
        }

        /// <summary>
        /// The constructor of BINARY criteria
        /// </summary>
        /// <param name="left">Indicate the LEFT property operand</param>
        /// <param name="right">Indicate the RIGHT operand</param>
        /// <param name="comparison">Indicate the comparison</param>
        public BinaryCriteria(string left, Operand right, BinaryComparison comparison)
        {
            Left = new OperandProperty(left);
            Right = right;
            Comparison = comparison;
        }

        /// <summary>
        /// The constructor of BINARY criteria
        /// </summary>
        /// <param name="left">Indicate the LEFT operand</param>
        /// <param name="right">Indicate the RIGHT operand</param>
        /// <param name="comparison">Indicate the comparison</param>
        public BinaryCriteria(Operand left, Operand right, BinaryComparison comparison)
        {
            Left = left;
            Right = right;
            Comparison = comparison;
        }
    }
}
